package com.lyk.swap.orm;

import java.util.Date;

import com.lyk.swap.struts.action.BaseAction;

/**
 * Price entity. @author MyEclipse Persistence Tools
 */

public class Price implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 7242274487553194699L;
	private Product product;
	private Date time;
	private Double price;

	// Constructors

	/** default constructor */
	public Price() {
	}

	/** full constructor */
	public Price(Product product, Date time, Double price) {
		this.product = product;
		this.time = time;
		this.price = price;
	}

	// Property accessors

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder(product.getCode());
		builder.append(' ');
		builder.append(BaseAction.format(time));
		builder.append(": ");
		builder.append(BaseAction.format(price));
		return builder.toString();
	}

	@Override
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (other == null)
			return false;
		if (!(other instanceof Price))
			return false;
		Price castOther = (Price) other;
		return (this.getProduct() == castOther.getProduct() || (this
				.getProduct() != null && castOther.getProduct() != null && this
				.getProduct().equals(castOther.getProduct())))
				&& (this.getTime() == castOther.getTime() || (this.getTime() != null
						&& castOther.getTime() != null && this.getTime()
						.equals(castOther.getTime())))
				&& (this.getPrice() == castOther.getPrice() || (this.getPrice() != null
						&& castOther.getPrice() != null && this.getPrice()
						.equals(castOther.getPrice())));
	}

	@Override
	public int hashCode() {
		int result = 17;
		result = 37 * result
				+ (getProduct() == null ? 0 : getProduct().hashCode());
		result = 37 * result + (getTime() == null ? 0 : getTime().hashCode());
		return result;
	}

}